import request from '@/router/axios';

let apiUrl = '/api/blade-message' // 代理接口地址
// let apiUrl = 'test'  // 后台本地接口地址


// 添加平台消息
export const centerPlatform = (form) => {
  return request({
    url: apiUrl + '/publicMessage',
    method: 'post',
    data: form
  })
}

// 查询平台消息（分页）
export const centerPlatList= (pageNo, pageSize, keyWord, isRead) => {
  return request({
    url: apiUrl + '/publicMessage/page',
    method: 'get',
    params: {
      pageNo,
      pageSize,
      keyWord,
      isRead
    }
  })
}

// 用户接受消息（分页）
export const userMessage= (pageNo, pageSize, keyWord,messageType, isRead) => {
  return request({
    url: apiUrl + '/userMessage/page',
    method: 'get',
    params: {
      pageNo,
      pageSize,
      keyWord,
      messageType, // 请求消息类型
      isRead
    }
  })
}

export const queryMessageList= () => {
  return request({
    url: apiUrl + '/userMessage/nonQueryList',
    method: 'get'
  })
}


// 推送平台消息
export const send= (id) => {
  return request({
    url: apiUrl + `/publicMessage/send/${id}`,
    method: 'put'
  })
}

// 删除消息
export const deleteMsg= (id) => {
  return request({
    url: apiUrl + `/publicMessage/${id}`,
    method: 'delete'
  })
}

// 已收消息（分页）
export const receivedNews = (pageNo, pageSize, keyWord) => {
  return request({
    url: apiUrl + '/publicMessage/recv/page',
    method: 'get',
    params: {
      pageNo,
      pageSize,
      keyWord
    }
  })
}

// 用户消息详情
export const messageDetail = (id) => {
  return request({
    url: apiUrl + `/userMessage/${id}`,
    method: 'get'
  })
}

// 单个标位已读（分页）
export const isRead = (id) => {
  return request({
    url: apiUrl + `/userMessage/${id}/isRead`,
    method: 'put'
  })
}

// 全部标为已读（分页）
export const allRead = () => {
  return request({
    url: apiUrl + `/userMessage/all/isRead`,
    method: 'put'
  })
}

// 信息数量统计
export const messageCount = () => {
  return request({
    url: apiUrl + `/userMessage/count`,
    method: 'get'
  })
}


